#pragma once

#include <Windows.h>
#include <vector>
#include "Vector.h"
#include <AntTweakBar.h>


class Line;
class BodyInfo;
class Connection;

class Renderer 
{
public:
	Renderer()	:	airjetStart(Vector(0,0)), airjetEnd(Vector(0, -20)), bAirjetActive(false), zoom(25.0f),
					translation(Vector(0,0)), bDrawSpring(false) {}
	~Renderer() {}

	bool		isNan(Vector v);

	int			init(HWND hwnd, int width, int height);
	void		draw(Line* lines, int nLines);
	void		draw(BodyInfo* circles, int nCircles);
	void		draw(Vector* rope, int ropePoints);

	void		clear();
	void		present();
	void		initGUI();

	void		setTotalObjects(int v);
	void		setAirjetForce(float v);
	void		setElasticity(float v);
	void		setFriction(float v);
	void		setGraphicsFreq(float v);
	void		setNetworkFreq(float v);
	void		setPhysicsFreq(float v);

	float		getGraphicsFreq();
	float		getNetworkFreq();
	float*		getPtrObjectsPerSec();

	void		setAirjetStart(Vector p) { airjetStart = p; }

	Vector*		getAirjetStart() { return &airjetStart; }
	Vector*		getAirjetEnd()   { return &airjetEnd;   }
	bool		airjetActive() { return bAirjetActive; }
	void		setAirjetActive(bool v) { bAirjetActive = v; }

	void		startTimer();
    double		getDeltaTime();
	double		getTime();

	void		changeZoom(float v);

	void		changePosition(float x, float y);
	void		resetView();

	float		getZoom() { return zoom; }

	Vector		getTranslation() { return translation; }

	bool		bDrawSpring;

	Connection*	m_connection;

private:
	void initialiseOpenGL(HWND hwnd, int width, int height);

	bool		bAirjetActive;
	Vector		airjetEnd;
	Vector		airjetStart;

	Vector		translation;

	__int64		start;
	double		freq;

	float		zoom;

	TwBar*		twBar;
	HDC			m_hDC;
};